package com.example.myapplication;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

/**
 * Created by yls on 2018/10/28.
 */

public class MyBroadcastReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();

        if (action.equals("Weather_Report")){
            String weather = intent.getStringExtra("Weather");
            int temp = intent.getIntExtra("temprature",0);
            Log.e("MyBroadcastReceiver","收到天气广播,天气"+weather+"温度"+temp);

        }
        else if (action.equals("Trafic_Report")){
            String trafic = intent.getStringExtra("Trafic");
            int time = intent.getIntExtra("Time", 0);
            Log.e("MyBroadcastReceiver", "收到交通广播,交通" + trafic + "时间" + time);

        }
    }
}